package fab_api.fat;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.springframework.util.Base64Utils;

import com.google.gson.Gson;
import com.google.inject.Inject;

import fab_api.SSLClient;
import io.practiceinsight.pinpayments.ParamsHelper;
import io.practiceinsight.pinpayments.http.HttpMethod;
import io.practiceinsight.pinpayments.http.HttpResponse;
import io.practiceinsight.pinpayments.http.HttpTransport;
import io.practiceinsight.pinpayments.pojo.ErrorResponseCard;
import io.practiceinsight.pinpayments.pojo.ResponseCard;
import io.practiceinsight.pinpayments.utils.PinPayHttpUtils;
import net.sf.json.JSONObject;

public class PinPon {
	 @Inject
	  private ParamsHelper paramsHelper;
	 
		static String encoding = new String(Base64Utils.encode("udYh_uLZKYnU1OQbYts-7g".getBytes()));//加密的账号密码
	public static void main(String[] args) {
//		paramsHelper.toFlatParams(card)
		Map<String, String> flatParams = new HashMap<>();
		flatParams.put("number", "5520000000000000");
		flatParams.put("expiry_month", "05");
		flatParams.put("expiry_year", "2019");
		flatParams.put("cvc", "123");
		flatParams.put("name", " Roland sd");
	//	flatParams.put("address_line1", "42 Sevenoaks St");
		//flatParams.put("address_city", "Lathlain");
		
		flatParams.put("address_postcode", "6454");
		flatParams.put("address_state", "WA");
		flatParams.put("address_country", "Australia");
		//udYh_uLZKYnU1OQbYts-7g
		    try {
				final HttpResponse httpResponse = new HttpTransport()
				        .addHeader("Content-Type", "application/x-www-form-urlencoded")
				        .addHeader("Authorization", "Basic "+encoding)
				        
				        .setHttpMethod(HttpMethod.POST)
				        .setUrl("https://test-api.pinpayments.com/1/cards")
				        .addParams(flatParams)
				        .execute();
				System.out.println("Basic="+"Basic "+encoding);
				System.out.println("httpResponse="+httpResponse);
				System.out.println(httpResponse.getContent());
				System.out.println(httpResponse.getError());
				System.out.println(httpResponse.getStatusCode());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}
//		@Inject
//		  private static Gson gson;
//		public static void main(String[] args) {
//			Map<String, String> flatParams = new HashMap<>();
//			flatParams.put("number", "5520000000000000");
//			flatParams.put("expiry_month", "05");
//			flatParams.put("expiry_year", "2019");
//			flatParams.put("cvc", "123");
//			flatParams.put("name", "Roland Robot");
//			flatParams.put("address_line1", " ");
//			flatParams.put("address_city", " ");
			/*
			flatParams.put("address_postcode", "6454");
			flatParams.put("address_state", "WA");*/
//			flatParams.put("address_country", "Australia");
//			PinPayHttpUtils.sendPinPayCreateCardPost(flatParams);
//			Map<String, String> sendMap=new HashMap<>();
//	    	sendMap.put("amount", "100");//需要支付的金额
//	    	sendMap.put("currency", "AUD");
//	    	sendMap.put("description", "Earnings for may");
//	    	sendMap.put("recipient", "rp_Q-JY4vPUuaPQv4oVf_WYDA");
//	    	System.out.println(PinPayHttpUtils.sendPinPayCreateTransfersPost(sendMap));
//		}
}
